# coding=utf-8
from image import *
from convolutional_network import *

if __name__ == "__main__":
    # 这里的文件路径默认是当前工作路径，也可以自己定义成绝对路径。
    img = load_image("static\\test_36X36.png")

    data = np.array((get_matrix(img, 0, 1), get_matrix(img, 1, 1), get_matrix(img, 2, 1)))
    # print(get_matrix(data, 0).shape)
    # show_image(get_matrix(data, 0))
    # show_image(get_matrix(data, 1))
    # show_image(get_matrix(data, 2))

    kernel_width = 5
    kernel_height = 5

    convolved_feature_layer = ConvolvedFeatureLayer(6)
    convolved_feature_layer.handler(data, kernel_width, kernel_height)

    # for index in range(len(convolved_feature_layer.maps)):
    #     show_image(convolved_feature_layer.maps[index])

    # print(np.array(convolved_feature_layer.maps).shape)

    pool = max_pooling_handler(convolved_feature_layer.maps)

    # print(np.array(pool).shape)

    # for index in range(len(pool)):
    #     show_image(pool[index])

    convolved_feature_layer2 = ConvolvedFeatureLayer(12)
    convolved_feature_layer2.handler(pool, kernel_width, kernel_height)

    for index in range(len(convolved_feature_layer2.maps)):
        show_image(convolved_feature_layer2.maps[index])
